]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
scroll-view-fade: Clean up GLSL
authorJasper St. Pierre <jstpierre@mecheye.net>
Wed, 28 Nov 2012 21:51:37 +0000 (16:51 -0500)
committerJasper St. Pierre <jstpierre@mecheye.net>
Thu, 29 Nov 2012 21:17:09 +0000 (16:17 -0500)
Basic cleanup of what we're doing already. This moves a bunch
of the "inside the fade area" checks to the top, before doing
any calculations.

https://bugzilla.gnome.org/show_bug.cgi?id=689249

src/st/st-scroll-view-fade.glsl

index 2e404200abf679be46470307239a9ade3db82dcc..9248fa6f0af4dd355889062f171e434585150a1c 100644 (file)
@@ -38,9 +38,15 @@ uniform mat2 fade_area;
 
 void main ()
 {
-    vec4 color = cogl_color_in * texture2D (tex, vec2 (cogl_tex_coord_in[0].xy));
+    cogl_color_out = cogl_color_in * texture2D (tex, vec2 (cogl_tex_coord_in[0].xy));
+
     float y = height * cogl_tex_coord_in[0].y;
     float x = width * cogl_tex_coord_in[0].x;
+
+    if (x < fade_area[0][0] || x > fade_area[1][0] ||
+        y < fade_area[0][1] || y > fade_area[1][1])
+        return;
+
     float ratio = 1.0;
     float fade_bottom_start = fade_area[1][1] - offset_bottom;
     float fade_right_start = fade_area[1][0] - offset_right;
@@ -49,10 +55,10 @@ void main ()
     float ratio_left = x / offset_left;
     float ratio_right = (fade_area[1][0] - x)/(fade_area[1][0] - fade_right_start);
     bool in_scroll_area = fade_area[0][0] <= x && fade_area[1][0] >= x;
-    bool fade_top = y < offset_top && in_scroll_area && (y >= fade_area[0][1]);
-    bool fade_bottom = y > fade_bottom_start && in_scroll_area && (y <= fade_area[1][1]);
-    bool fade_left = x < offset_left && in_scroll_area && (x >= fade_area[0][0]);
-    bool fade_right = x > fade_right_start && in_scroll_area && (x <= fade_area[1][0]);
+    bool fade_top = y < offset_top;
+    bool fade_bottom = y > fade_bottom_start;
+    bool fade_left = x < offset_left;
+    bool fade_right = x > fade_right_start;
 
     if (fade_top) {
         ratio *= ratio_top;
@@ -70,5 +76,5 @@ void main ()
         ratio *= ratio_right;
     }
 
-    cogl_color_out = color * ratio;
+    cogl_color_out *= ratio;
 }